using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Microsoft.CommerceServer.SecureSite
{
    public class OrdersWebService : Microsoft.CommerceServer.SecureSite.Wizard
    {
        private System.Windows.Forms.Panel pnlOrders;
        private System.Windows.Forms.DataGrid dtGrdRoles;
        private System.Windows.Forms.Label lblRoleInstructions;
        private System.ComponentModel.IContainer components = null;

        public OrdersWebService()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            // 
            // btnNext
            // 
            this.btnNext.Name = "btnNext";
            // 
            // btnPrevious
            // 
            this.btnPrevious.Name = "btnPrevious";
            // 
            // MarketingWebService
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(552, 374);
            this.Name = "OrdersWebService";
            this.Load += new System.EventHandler(this.OrdersWebService_Load);
            this.Activated += new System.EventHandler(this.OrdersWebService_Activated);


            this.components = new System.ComponentModel.Container();
        }

        #endregion

        protected override void btnPrevious_Click(object sender, System.EventArgs e)
        {
            CommerceSecurityInfo.MoveToForm("MarketingWebService");
            base.Visible = false;
        }

        protected override void btnNext_Click(object sender, System.EventArgs e)
        {
            if (base.IsValid)
            {
                CommerceSecurityInfo.MoveToForm("ProfilesWebService");
                base.Visible = false;
            }
        }

        private void OrdersWebService_Load(object sender, System.EventArgs e)
        {
            this.pnlOrders = new System.Windows.Forms.Panel();
            this.dtGrdRoles = new System.Windows.Forms.DataGrid();
            this.lblRoleInstructions = new System.Windows.Forms.Label();
            this.pnlOrders.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dtGrdRoles)).BeginInit();
            this.SuspendLayout();
            // 
            // btnNext
            // 
            this.btnNext.Name = "btnNext";
            // 
            // btnPrevious
            // 
            this.btnPrevious.Name = "btnPrevious";
            // 
            // pnlMarketing
            // 
            this.pnlOrders.Controls.Add(this.dtGrdRoles);
            this.pnlOrders.Controls.Add(this.lblRoleInstructions);
            this.pnlOrders.Dock = System.Windows.Forms.DockStyle.Fill;
            this.pnlOrders.Location = new System.Drawing.Point(0, 72);
            this.pnlOrders.Name = "pnlOrders";
            this.pnlOrders.Size = new System.Drawing.Size(552, 262);
            this.pnlOrders.TabIndex = 4;
            // 
            // dtGrdRoles
            // 
            this.dtGrdRoles.DataMember = "";
            this.dtGrdRoles.HeaderForeColor = System.Drawing.SystemColors.ControlText;
            this.dtGrdRoles.Location = new System.Drawing.Point(32, 72);
            this.dtGrdRoles.Name = "dtGrdRoles";
            this.dtGrdRoles.Size = new System.Drawing.Size(480, 176);
            this.dtGrdRoles.TabIndex = 1;
            // 
            // lblRoleInstructions
            // 
            this.lblRoleInstructions.Location = new System.Drawing.Point(40, 16);
            this.lblRoleInstructions.Name = "lblRoleInstructions";
            this.lblRoleInstructions.Size = new System.Drawing.Size(464, 48);
            this.lblRoleInstructions.TabIndex = 0;
            this.lblRoleInstructions.Text = "label1";
            // 
            // MarketingWebService
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(552, 374);
            this.Controls.Add(this.pnlOrders);
            this.Name = "OrdersWebService";
            this.Controls.SetChildIndex(this.pnlOrders, 0);
            this.pnlOrders.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.dtGrdRoles)).EndInit();
            this.ResumeLayout(false);

            CommerceSecurityInfo.Log("FORM: Orders Web Service form loaded");
            base.Title = "Orders WebSerivce Roles";
            this.lblRoleInstructions.Text = "Enter user name to access Orders WebService.";

            loadOrderRoles();
        }

        private void loadOrderRoles()
        {
            CommerceSecurityInfo.Ordrwebsvr = new CSWebService(WebServiceType.ordersWebService);

            try
            {
                CommerceSecurityInfo.SetAzManDataGrid(CommerceSecurityInfo.Ordrwebsvr, dtGrdRoles, this.BindingContext);
            }
            catch (Exception ex)
            {
                CommerceSecurityInfo.Log("Error: " + ex.Message);
                this.lblRoleInstructions.Text = "No Orders WebService to set roles. Click the Next button To Continue.";
            }
        }

        private void OrdersWebService_Activated(object sender, System.EventArgs e)
        {
            if (CommerceSecurityInfo.IsDirty)
            {
                this.OrdersWebService_Load(sender, e);
            }
        }
    }
}

